/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            shopAccountDetailManageInfo: {
                shopAccountDetails: [],
                shopAccounts: [],
                total: 0,
                records: 1,
                moreCondition: false,
                scId: '',
                detailTypes: [],
                conditions: {
                    acctId: '',
                    detailType: '',
                    orderId: ''
                }
            }
        },
        _initMethod: function () {
            $that._loadShopAccounts();
            $that._listshopAccountDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            vc.getDict('account_detail', "detail_type", function (_data) {
                $that.shopAccountDetailManageInfo.detailTypes = _data;
            });
        },
        _initEvent: function () {
            vc.on('shopAccountDetailManage', 'listshopAccountDetail', function (_param) {
                $that._listshopAccountDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listshopAccountDetails(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listshopAccountDetails: function (_page, _rows) {
                $that.shopAccountDetailManageInfo.conditions.page = _page;
                $that.shopAccountDetailManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.shopAccountDetailManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/account/queryAccountDetail',
                    param,
                    function (json, res) {
                        var _shopAccountDetailManageInfo = JSON.parse(json);
                        $that.shopAccountDetailManageInfo.total = _shopAccountDetailManageInfo.total;
                        $that.shopAccountDetailManageInfo.records = _shopAccountDetailManageInfo.records;
                        $that.shopAccountDetailManageInfo.shopAccountDetails = _shopAccountDetailManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.shopAccountDetailManageInfo.records,
                            dataCount: $that.shopAccountDetailManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _queryshopAccountDetailMethod: function () {
                $that._listshopAccountDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetshopAccountDetailMethod: function () {
                $that.shopAccountDetailManageInfo.conditions.acctId = "";
                $that.shopAccountDetailManageInfo.conditions.detailType = "";
                $that.shopAccountDetailManageInfo.conditions.orderId = "";
                $that._listshopAccountDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.shopAccountDetailManageInfo.moreCondition) {
                    $that.shopAccountDetailManageInfo.moreCondition = false;
                } else {
                    $that.shopAccountDetailManageInfo.moreCondition = true;
                }
            },
            _loadShopAccounts: function (_page, _rows) {
                let param = {
                    params: {
                        page: 1,
                        row: 50
                    }
                };
                //发送get请求
                vc.http.apiGet('/account/queryAccount',
                    param,
                    function (json, res) {
                        let _shopAccountManageInfo = JSON.parse(json);
                        $that.shopAccountDetailManageInfo.shopAccounts = _shopAccountManageInfo.data;
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            }
        }
    });
})(window.vc);
